

CurrentFeed = GetOemDRO(818)	'Save the current front feed settings
DoSpinStop()	'Spindle stop

Cur = GetDro(0) 		'Read x-coordinate
Move = Cur-20.0 		'The maximum depth of detection is 20.0
Offset = Abs(GetOEMDRO(1000))/(2) 	'The radius of the finder. It has to be compensated for.
Sal = Offset + 2.0 	'When tool setting is complete, leave the workpiece 2.0

If GetOemLed (825)=0 Then	'Determines if the edge finder is in contact with the workpiece. The edge finder can only run if there is no contact at the start
Code "G4 P2.5"	'Pause 2.5s
Code "G31 X"& Move & "F25"	'x-axis edge finding at a feed rate of 25
While IsMoving()		'Wait for edge detection to stop
Sleep(200)
Wend
Probepos = GetDro(0)		'
Call SetDro(0, Offset)		'Setting the new x-origin
Code "G4 P1"			'pause 
Code "G0 X" & Sal		'regression
Code "(X zeroed)"		'Alerts
Code "F" &CurrentFeed 	'Restore original feed settings

Else
Code "(Check Ground Probe)"	'Probe is shorted to ground (contact with workpiece), abort.
End If

Exit Sub   
